<?php

if(!isset($_SESSION)) session_start();
$form = f()->users()->user_form('register');
if ($form->submitted()) {
	$fields = array('id','first_name','last_name','user_state','gender','date_of_birth',
		'address','city','state','country','zip','email','phone','mobile');
	$o = f()->users()->user();
	$form->load();
	$form->save($o,$fields);
	$o->change_password($form->value('password1'));
	$o->user_state = f()->users()->enable_account_after_registration ? 
		'ENABLED' : 'DISABLED';
	$o->save();
	$this->redirect($_SESSION['_f_register_redirect_page']);
} else {
	$_SESSION['_f_register_redirect_page'] = $_SERVER['HTTP_REFERER'];	
	$form->render();
}
